package com.xidian.zhiancloud.service.warnforecast.keypointernotific;

import com.xidian.zhiancloud.dao.KeyStatisticalIndicatorsMapper;
import com.xidian.zhiancloud.dto.KeyStatisticalIndicatorsDTO;
import com.xidian.zhiancloud.dto.ResultDTO;
import com.xidian.zhiancloud.enums.GeneralResponseEnums;
import com.xidian.zhiancloud.model.KeyStatisticalIndicators;
import com.xidian.zhiancloud.model.KeyStatisticalIndicatorsExample;
import com.xidian.zhiancloud.service.warnforecast.basicsset.WarnLevelSetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 关键指标统计
 */

@Service
public class KeyStatisticalIndicatorsService {
    @Autowired
    private KeyStatisticalIndicatorsMapper keyStatisticalIndicatorsMapper;

    public List<KeyStatisticalIndicatorsDTO> getList() {
        // 类型,0：风险分级管控，1：隐患排查治理，2：三违管理，3：系统运行情况
        int type[] = {0,1,2,3};
        List<int[]> ints = Arrays.asList(type);
        KeyStatisticalIndicatorsDTO keyStatisticalIndicatorsDTO = null;

        KeyStatisticalIndicatorsExample example = new KeyStatisticalIndicatorsExample();
        //查询数据
        List<KeyStatisticalIndicators> keyStatisticalIndicators = keyStatisticalIndicatorsMapper.selectByExample(example);

       List<KeyStatisticalIndicatorsDTO> dtoList = new ArrayList<>();
        for (int i = 0; i < 4; i++) {
            keyStatisticalIndicatorsDTO = new KeyStatisticalIndicatorsDTO();
            keyStatisticalIndicatorsDTO.setType(i);
            List<KeyStatisticalIndicators> indicatorsList = new ArrayList<>();
            for (KeyStatisticalIndicators keyStatisticalIndicator : keyStatisticalIndicators) {
                if (i == keyStatisticalIndicator.getType()) {
                    indicatorsList.add(keyStatisticalIndicator);
                }
                keyStatisticalIndicatorsDTO.setKeyStatisticalIndicatorsList(indicatorsList);
            }
            dtoList.add(keyStatisticalIndicatorsDTO);
        }
        return dtoList;
    }
}
